package com.jb.platform.admin.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author AnTi
 * @date 2024年05月13日
 */
@Controller
@RequestMapping("/index")
public class IndexController {

    @GetMapping("/index")
    public String index(ModelMap mode){
        mode.addAttribute("user","张三");
        mode.addAttribute("button","<button id=\"click\" onclick=\"testClick()\">点击</button><button id=\"btn\" >点击2</button><button id=\"loginBtn\" >点击3</button>");
        mode.addAttribute("javascript",
                "<script type=\"text/javascript\">\n" +
                        "   $(function () {$(\"#loginBtn\").on('click', function () {" +
                        "     alert(\"这是第12种点击方式\");" +
                        "})"+
                        "\n"+
                        "document.getElementById(\"btn\").onclick = function(){\n" +
                        "            alert(\"这是第1种点击方式\");\n" +
                        "}     " +
                        "    })" +
                        "\n"+
                        "function testClick() {\n" +
                        "        var v=document.getElementById(\"test_input\").value;\n" +
                        "       $.ajax({\n" +
                        "                type: \"get\",\n" +
                        "                url: \"/user/test?id=\"+v,\n" +
                        "                success: function (data) {\n" +
                        "                }\n" +
                        "            });" +
                        "    }" +

                "</script>\n");
        return "index";
    }

}
